import os
import sys

from launch import LaunchDescription, LaunchIntrospector, LaunchService
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory


def generate_launch_description():

    return LaunchDescription([
        Node(
            package='ultrasonic_node',
            executable='ultrasonic_node',  # 使用 executable 来指定可执行文件
            name='ultrasonic_node',
            output='screen',
            parameters=[],
        ),
    ])

def main(argv):
    ld = generate_launch_description()

    print('Starting introspection of launch description...')
    print('')

    print(LaunchIntrospector().format_launch_description(ld))

    print('')
    print('Starting launch of launch description...')
    print('')

    ls = LaunchService()
    ls.include_launch_description(ld)
    return ls.run()


if __name__ == '__main__':
    main(sys.argv)